<%@ page language="java" pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<%@ taglib prefix="product" tagdir="/WEB-INF/tags/product"%>
<%@ taglib prefix="system" tagdir="/WEB-INF/tags/system"%>
<%@ taglib prefix="sales" tagdir="/WEB-INF/tags/sales"%>

<table border="0" cellspacing="0" cellpadding="0" class="table_cart">
	<tr>
			<td class="t_promotion">
				<!-- 促销信息开始 -->
				<c:set value="false" var="ifPromo"/>
				<c:if test="${not empty shoppingcart.shoppingCartPromotions}">
					<c:set value="true" var="ifPromo"/>
					<h6><fmt:message key="shoppingcart.promoTip"/>:</h6>
					<ul>
						<c:forEach var="promotion" items="${shoppingcart.shoppingCartPromotions}">
							<li><h3><a href="<sales:promoRuleUrl promoRuleId="${promotion.promoRuleId}"/>" target="_blank" title="${promotion.promotionName}">${promotion.promotionName}</a></h3></li>
						</c:forEach>
					</ul>
				</c:if>
				<!-- 促销信息结束 -->
				
				<!-- 获得赠送的优惠券信息 -->
				<c:if test="${not empty coupon}">
					<c:set value="true" var="ifPromo"/>
					<h6><fmt:message key="checkout.gainCoupon" />：</h6>
					<ul>
						<li><h3><a href="<sales:promoRuleUrl promoRuleId="${coupon.promoRuleId}"/>" target="_blank" title="${coupon.name}">${coupon.name}</a></h3></li>
					</ul>	
				</c:if>
				<!-- 获得赠送的优惠券信息结束 -->
				
				<!--  积分信息开始 -->
				<c:if test="${shoppingcart.gainedPoint!=0}">
					<c:set value="true" var="ifPromo"/>
					<h6><fmt:message key="checkout.gainPoint" />：${shoppingcart.gainedPoint}</h6>
				</c:if>
				<!--  积分信息结束 -->
				<c:if test="${not ifPromo}">
					<h6><i18n:msg expr="shoppingcart.promoNull" arg1="${ctxPath}/promo.html"></i18n:msg> </h6>
				</c:if>
				<!--  礼品信息开始 -->
				<c:if test="${not empty shoppingcart.promoGiftList}">
					<c:set value="true" var="ifPromo"/>
					<div class="promoGift clearfix">
						<h6><fmt:message key="checkout.gainGift" /></h6>
						<ul class="jcarousel-skin-probizStyle3" id="slide_gift" style="display:none;">
							<c:forEach var="promoGift" items="${shoppingcart.promoGiftList}">
								<li>
	                                <div class="pic"><sales:giftImage id="giftImage" gift="${promoGift}" sizeType="s0" linkType="2" width="58" height="58" /></div>
	                                <h4>${promoGift.giftName}</h4>
	                                <span><fmt:message key="productSku.promotion.gift.num"/> : <b>${promoGift.orderSkuQuantity}${promoGift.weightMeasureUnitName}</b></span>
	                            </li>
							</c:forEach>
						</ul>
					</div>
				</c:if>
				<!--  礼品信息结束 -->
				<br>
				<!--  即将满足的促销优惠列表 -->
				<ul>
					<c:forEach items="${shoppingcart.shoppingCartItems}" var="item" varStatus="status">
						<c:choose>
							<c:when test="${item.isOnSale eq 1}">
								<li>
									<h6>
										<fmt:message key="shoppingcart.salePrice">
											<fmt:param>${item.productSku.product.productName }</fmt:param>
										</fmt:message>
									</h6>
								</li>
							</c:when>
							<c:otherwise>
								<ul id="proms"></ul>
							</c:otherwise>
						</c:choose>
					</c:forEach>
				</ul>
			</td>
			<td colspan="4" class="t_charge" width="50%">
				<table border="0" cellspacing="0" cellpadding="0" class="table_charge" align="right">
						<c:set var="label"><fmt:message key="checkout.couponNo" /></c:set>
						<c:set var="onclick">useCoupon($j('#couponNo').val())</c:set>
						<c:set var="buttonLabel"><fmt:message key="checkout.use"/></c:set>
						<c:if test="${shoppingcart.couponApplied}">
							<c:set var="label"><fmt:message key="checkout.message.applyCouponSuccess" /></c:set>
							<c:set var="onclick">unuseCoupon()</c:set>
							<c:set var="buttonLabel"><fmt:message key="checkout.notUse"/></c:set>
						</c:if>
						<tr>
								<th>${label}:</th>
								<td>
									<c:if test="${not shoppingcart.couponApplied}">
										<input type="text" id="couponNo" name="couponNo" class="inputtxt" />&nbsp;
									</c:if>
									<a href="javascript:void(0)" onclick="${onclick}">${buttonLabel}</a>
									<!-- 
									<a href="" onclick="${onclick}"><img src="${txtImagePath}/btn_use.gif" alt="使用" /></a>
									 -->
								</td>
						</tr>
						<tr>
								<th><fmt:message key="shoppingcart.subtotal"/>：</th>
								<td><common:currencyFormat value="${shoppingcart.subtotal}"/></td>
						</tr>
						<tr>
								<th><fmt:message key="shoppingcart.saveMoneyTotal"/>：</th>
								<td><common:currencyFormat value="${shoppingcart.cartDiscountAmount}"/></td>
						</tr>
						<tr>
								<th><fmt:message key="shoppingcart.total"/>：</th>
								<td><b class="total"><common:currencyFormat value="${shoppingcart.total}"/></b></td>
						</tr>
				</table>
			</td>
	</tr>
	<tr>
			<td colspan="5" class="t_checkout">
				<c:choose>
					<c:when test="${not empty outOfStockException}">
						<span class="red">
							<fmt:message key="shoppingcart.message.stockLack">
								<fmt:param value=" ${outOfStockException.productSku.product.productName} ${outOfStockException.productSku.orderSkuDisplayOption}"/>
							</fmt:message>
						</span>
					</c:when>
					<c:otherwise>
						<a id="btnContinue" href="${ctxPath}/index.html"><img src="${txtImagePath}/btn_continue_shopping.gif" width="115" height="39" alt="<fmt:message key="shoppingcart.continue" />" /></a>
						<c:choose>
							<c:when test="${shoppingcart.belowMinimumPurchaseAmount}">
								<c:set var="minPurchaseAmountMsg">
									<fmt:message key="shoppingcart.detail.underMinimumPurchaseAmount">
										<fmt:param value="${appConfig.minimumPurchaseAmount}"/>
									</fmt:message>
								</c:set>
								
								<a id="btnCheckout" href="javascript:void(0)" onclick="alert('${minPurchaseAmountMsg}'); return false;" title="${minPurchaseAmountMsg}"><img src="${txtImagePath}/btn_checkout0.gif" alt="<fmt:message key="shoppingcart.checkout" />" /></a>
							</c:when>
							<c:otherwise>
								<a id="btnCheckout" href="javascript:void(0)" onclick="toCheckout();"><img src="${txtImagePath}/btn_checkout.gif" alt="<fmt:message key="shoppingcart.checkout" />" /></a>
							</c:otherwise>
						</c:choose>
						<i class='loading' style="display:none;"><fmt:message key="shoppingcart.message.toCheckout"/></i>
					</c:otherwise>
				</c:choose>
			</td>
	</tr>
</table>

<script type="text/javascript">
$j(document).ready(function () {
	if (${shoppingcart.itemsCount >0}){
		getPromoValue();
	}
	try{
		$j('#slide_gift').show();
		$j('#slide_gift').jcarousel();
	}catch(Exception){}
});
</script>
